home *** CD-ROM | disk | FTP | other *** search
/ Playboy Electronic Datebook / Playboy Electronic Datebook - Disk 2.img / MSREGDB.IN_ / MSREGDB.IN
Text File  |  1993-10-22  |  3KB  |  90 lines

  1. '********************   Modified REGDB.INC    ******************************
  2. '***************************************************************************
  3. '****************     registration database api's    ***********************
  4. '***************************************************************************
  5.  
  6. '$DEFINE REG_DB_ENABLED
  7.  
  8. const REG_SZ               = 1
  9. const HKEY_CLASSES_ROOT    = 1
  10. const ERROR_SUCCESS        = 0
  11.  
  12.  
  13. DECLARE FUNCTION EercErrorHandler LIB "mscomstf.dll" (grc%, fVital%, sz1$, sz2$, sz3$) AS INTEGER
  14. CONST GRC_API_FAILED       = 104
  15.  
  16. DECLARE FUNCTION RegOpenKey LIB "SHELL.DLL" (hKey&, szSubKey$, phkResult AS POINTER TO LONG) AS LONG
  17. DECLARE FUNCTION RegCreateKey LIB "shell.dll" (hKey&, szSubKey$, phkResult AS POINTER TO LONG) AS LONG
  18. DECLARE FUNCTION RegDeleteKey LIB "shell.dll" (hKey&, szSubKey$) AS LONG
  19. DECLARE FUNCTION RegCloseKey LIB "shell.dll" (hKey&) AS LONG
  20. DECLARE FUNCTION RegQueryValue LIB "shell.dll" (hKey&, szSubKey$, szValue$, lpcb AS POINTER TO LONG) AS LONG
  21. DECLARE FUNCTION RegSetValue LIB "shell.dll" (hKey&, szSubKey$, dwType&, szValue$, cbValue&) AS LONG
  22. DECLARE FUNCTION RegEnumKey LIB "shell.dll" (HkEY&, dwIndex&, szBuffer$, dwBufferSize&) AS LONG
  23.  
  24.  
  25. DECLARE SUB CreateRegKey(szKey$)
  26. DECLARE SUB CreateRegKeyValue(szKey$, szValue$)
  27. DECLARE SUB DeleteRegKey(szKey$)
  28. DECLARE FUNCTION DoesRegKeyExist(szKey$) AS INTEGER
  29.  
  30.  
  31. 'NOTE: All keys are assumed to be subkeys of HKEY_CLASSES_ROOT. Therefore,
  32. 'the key HKEY_CLASSES_ROOT\key1\key2 would simply be written as key1\key2
  33. 'for these api's.
  34.  
  35.  
  36. '**************************************************************************
  37. SUB CreateRegKey(szKey$) STATIC
  38.     DIM phKey AS LONG
  39.  
  40.     IF RegCreateKey(HKEY_CLASSES_ROOT, szKey$, VARPTR(phKey)) > ERROR_SUCCESS THEN
  41.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKey", NULL, NULL)
  42. '$ifdef DEBUG
  43.         StfApiErr saeFail, "CreateRegKey", szKey$
  44. '$endif ''DEBUG
  45.         ERROR STFERR
  46.     END IF
  47.  
  48.     IF RegCloseKey(phKey) > ERROR_SUCCESS THEN
  49.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKey", NULL, NULL)
  50. '$ifdef DEBUG
  51.         StfApiErr saeFail, "CreateRegKey", szKey$
  52. '$endif ''DEBUG
  53.         ERROR STFERR
  54.     END IF
  55. END SUB
  56.  
  57.  
  58. '**************************************************************************
  59. SUB CreateRegKeyValue(szKey$, szValue$) STATIC
  60.     DIM phKey AS LONG
  61.  
  62.     IF RegSetValue(HKEY_CLASSES_ROOT, szKey$, REG_SZ,  szValue$, len(szKey$)) > ERROR_SUCCESS THEN
  63.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKeyValue", NULL, NULL)
  64. '$ifdef DEBUG
  65.         StfApiErr saeFail, "CreateRegKeyValue", szKey$+", "+szValue$
  66. '$endif ''DEBUG
  67.         ERROR STFERR
  68.     END IF
  69. END SUB
  70.  
  71.  
  72. '**************************************************************************
  73. FUNCTION DoesRegKeyExist(szKey$) STATIC AS INTEGER
  74.     DIM phKey AS LONG
  75.  
  76.     IF RegOpenKey(HKEY_CLASSES_ROOT, szKey$, VARPTR(phKey)) = ERROR_SUCCESS THEN
  77.         i = RegCloseKey(phKey)
  78.         DoesRegKeyExist = 1
  79.     ELSE
  80.         DoesRegKeyExist = 0
  81.     ENDIF
  82. END FUNCTION
  83.  
  84.  
  85. '**************************************************************************
  86. SUB DeleteRegKey(szKey$) STATIC
  87.     i& = RegDeleteKey(HKEY_CLASSES_ROOT, szKey$)
  88. END SUB
  89.  
  90.